//
//  SQChangePasswordViewController.m
//  energy
//
//  Created by 周曼迪 on 2021/7/18.
//

#import "SQChangePasswordViewController.h"

#import "SQUserInformationModel.h"

@interface SQChangePasswordViewController ()
@property (weak, nonatomic) IBOutlet UITextField *tf_tel;
@property (weak, nonatomic) IBOutlet UITextField *tf_password;
@property (weak, nonatomic) IBOutlet UITextField *tf_password_new;

@end

@implementation SQChangePasswordViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"修改密码";
    self.tf_tel.text = self.tel;
}

//༥༤༽ཀབཀྲ་ཤིས་བདེ་ལེགས།
- (IBAction)clickConfirm:(UIButton *)sender {
    if ([self verifications]) {
        [SQUserInformationModel getDataWithParams:@{@"m_name":@"",@"m_phone":self.tf_tel.text,@"m_userpass":self.tf_password.text,@"m_id":UID} WithCallBack:^(SQUserInformationModel * data) {
            [CCToast showMessage:@"修改成功"];
            [[NSNotificationCenter defaultCenter] postNotificationName:@"userInformation" object:nil];
            [self.navigationController popViewControllerAnimated:YES];
            
        }];
    }
    
    
}

#pragma mark ---- 验证
- (BOOL)verifications{
    BOOL ret = NO;
    if([self.tf_password.text isEqualToString:@""]){
          
        [CCToast showMessage:@"请输入密码"];
           return NO;
    }else if (![self.tf_password.text validatePassWord]){
        [CCToast showMessage:@"必须包含字母数字和特殊字符的组合,长度在10-15之间"];
        return NO;
    }else if (![self.tf_password.text isEqualToString:self.tf_password_new.text]){
        [CCToast showMessage:@"两次密码不一致"];
        return NO;
    }else{
        ret = YES;
    }
    return YES;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
